<?php

namespace Home\Model;
use Think\Model;
class AreaModel extends BaseModel{
    
    //省市信息表
    protected $tableName = 'tp_area';
    
    /**
     * @desc 获取省市信息模型
     * @author quyang
     * @update 2016-11-28
     */
    public function getArea($where){
        $data = $this
                ->where($where)
                ->field('
                    f_id as areaCode,
                    f_areaname as areaName,
                    f_level as areaLevel,
                    f_parentid as parentCode
                    ')->select();
        return $data;
    }

    /**
     * @Desc  : 根据区域id获取省市信息
     * @Author：quyang
     * @Param ：
     * @Time  ：2017/3/10 14:16
     * @Update：2017/3/10
     **/
    public function getRegion( $where )
    {

        return $this->alias('a')
                ->where( $where )
                ->join('left join tp_area b on a.f_parentid = b.f_id')
                ->join('left join tp_area c on b.f_parentid = c.f_id')
                ->field(
                    'a.f_parentid as cityId,
                     c.f_id as provinceId'
                )->find();

    }

}